722B - Verse Pattern - CodeForces Solution


implementation strings *1200

Please click on ads to support us..

Python Code:

n=int(input())
p=list(map(int,input().split()))


for i in range(n):
    s=input()

    count=0
    for j in range(len(s)):
        if s[j]=='a' or s[j]=='e' or s[j]=='i' or s[j]=='o' or s[j]=='u' or s[j]=='y':
            count+=1

    if count!=p[i]:
        print("NO")
        exit(0)

print("YES")

C++ Code:

#include <bits/stdc++.h>
//#define int long long
using namespace std;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> cnt(n, 0);
    vector<int> p(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    string line;
    getline(cin, line);
    for (int i = 0; i < n; ++i) {
        getline(cin, line);
        for (auto c : line) {
            if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') {
                ++cnt[i];
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        if (cnt[i] != p[i]) {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
    return 0;
}


Comments

Submit
0 Comments
More Questions

Count of integers
Differences of the permutations
Doctor's Secret
Back to School
I am Easy
Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement
Numbers in a matrix
Sequences
Split houses
Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble
Help Jarvis!
Lift queries
Goki and his breakup
Ali and Helping innocent people